package com.repository.service.impl;

import com.repository.entity.ProductShipment;
import com.repository.dao.ProductShipmentDao;
import com.repository.service.ProductShipmentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 待出库表(ProductShipment)表服务实现类
 *
 * @author makejava
 * @since 2024-07-14 17:38:16
 */
@Service("productShipmentService")
public class ProductShipmentServiceImpl implements ProductShipmentService {
    @Resource
    private ProductShipmentDao productShipmentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param bottleLabel 主键
     * @return 实例对象
     */
    @Override
    public ProductShipment queryById(String bottleLabel) {
        return this.productShipmentDao.queryById(bottleLabel);
    }

    /**
     * 分页查询
     *
     * @param productShipment 筛选条件
     * @param pageRequest     分页对象
     * @return 查询结果
     */
   /* @Override
    public Page<ProductShipment> queryByPage(ProductShipment productShipment, PageRequest pageRequest) {
        long total = this.productShipmentDao.count(productShipment);
        return new PageImpl<>(this.productShipmentDao.queryAllByLimit(productShipment, pageRequest), pageRequest, total);
    }*/

    /**
     * 新增数据
     *
     * @param productShipment 实例对象
     * @return 实例对象
     */
    @Override
    public ProductShipment insert(ProductShipment productShipment) {
        this.productShipmentDao.insert(productShipment);
        return productShipment;
    }

    /**
     * 修改数据
     *
     * @param productShipment 实例对象
     * @return 实例对象
     */
    @Override
    public ProductShipment update(ProductShipment productShipment) {
        this.productShipmentDao.update(productShipment);
        return this.queryById(productShipment.getBottleLabel());
    }

    /**
     * 通过主键删除数据
     *
     * @param bottleLabel 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String bottleLabel) {
        return this.productShipmentDao.deleteById(bottleLabel) > 0;
    }
}
